package com.rxyb.sms.utils.keyou;

import java.util.Random;

public class RandomUtil {

    private static final String SOURCES =
            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";

    /**
     * Generate a random string.
     *
     * @param length the length of the generated string.
     * @return random string
     */
    public static String randomString(int length) {
        Random random = new Random();
        char[] text = new char[length];
        for (int i = 0; i < length; i++) {
            text[i] = SOURCES.charAt(random.nextInt(SOURCES.length()));
        }
        return new String(text);
    }

}
